'''
添加商机页
'''

from selenium.webdriver.common.by import By
from page.base_page import BasePage

class AddSjPage(BasePage):
    url="/crm/index.php?m=business&a=add"

    #定位器
    charge_name_locator=(By.CSS_SELECTOR,"#owner_name")
    charge_xiashu_select_locator=(By.CSS_SELECTOR,"#d_content > tr:nth-child(11) > td:nth-child(1) > input[type=radio]")
    charge_xiashu_select_ok_locator=(By.CSS_SELECTOR,"body > div:nth-child(19) > div.ui-dialog-buttonpane.ui-widget-"
                                                     "content.ui-helper-clearfix > div > button:nth-child(1)")
    customer_name_locator = (By.NAME, "customer_name")
    customer_select_locator = (By.CSS_SELECTOR, "#datas > tr:nth-child(1) > td:nth-child(1) > input[type=radio]:nth-child(1)")
    customer_select_ok_locator = (By.CSS_SELECTOR, "body > div:nth-child(17) > div.ui-dialog-""buttonpane.ui-widget-"
                                                   "content.ui-h""elper-clearfix > div > ""button:nth-child(1) > span")
    sj_name_locator = (By.NAME, "name")
    price_locator = (By.NAME, "estimate_price")
    save_locator = (By.CSS_SELECTOR, "#form1 > table > tfoot > tr > td > input:nth-child(1)")

    def click_charge_name(self):
        '''点击负责人输入框'''
        self.driver.find_element(*self.charge_name_locator).click()
    def click_charge_xiashu_select(self):
        '''弹窗中选择xiashu'''
        self.driver.find_element(*self.charge_xiashu_select_locator).click()
    def click_cahrge_xiashu_select_ok(self):
        self.driver.find_element(*self.charge_xiashu_select_ok_locator).click()
    def click_customer_name(self):
        '''点击客户输入框'''
        self.driver.find_element(*self.customer_name_locator).click()
    def customer_select(self):
        '''点击选择弹窗的第一个客户'''
        self.driver.find_element(*self.customer_select_locator).click()
    def customer_select_ok(self):
        '''选择客户后点击确定'''
        self.driver.find_element(*self.customer_select_ok_locator).click()
    def input_sj_name(self,sj_name):
        '''输入商机名'''
        self.driver.find_element(*self.sj_name_locator).send_keys(sj_name)
    def input_price(self,price):
        '''输入预计成交价'''
        self.driver.find_element(*self.price_locator).send_keys(price)
    def click_save(self):
        '''点击保存'''
        self.driver.find_element(*self.save_locator).click()